package com.kgis.fm.access.common.service.impl;

import com.kgis.kp.common.util.Assertion;
import com.kgis.kp.dao.statement.NamedStatementFactory;


/**
 *
 * @author zhxiaomiao
 * @version 1.0
 *
 */
public abstract class AbstractNamedStatementJdbcTemplateAccessServiceImpl extends AbstractJdbcTemplateAccessServiceImpl {

	public static final String SEPERATOR = ".";

	protected NamedStatementFactory namedStatementFactory;

	protected static String statementName(String namespace, String operation) {
		return namespace + SEPERATOR + operation;
	}

	protected String getNamedStatement(String statementName, Object parameter) {
		String namedStatement = namedStatementFactory.getNamedStatement(statementName, parameter);
		Assertion.notEmpty(namedStatement, "namedStatement not found, statementName=" + statementName);
		return namedStatement;
	}

	protected String getNamedStatement(String namespace, String operation, Object parameter) {
		return getNamedStatement(statementName(namespace, operation), parameter);
	}

	/**
	 * @return the namedStatementFactory
	 */
	public NamedStatementFactory getNamedStatementFactory() {
		return namedStatementFactory;
	}

	/**
	 * @param namedStatementFactory
	 *            the namedStatementFactory to set
	 */
	public void setNamedStatementFactory(NamedStatementFactory namedStatementFactory) {
		this.namedStatementFactory = namedStatementFactory;
	}

}
